package own.stu.jobgib.playown.vediodown.common.model;

import java.util.function.Function;

/**
 *  pass, pass ....| checkPoint | notPass, notPass
 * @param <ItemContent>
 */
public class ItemFilter<ItemContent> {

    private boolean isFilterFlag = true;

    private Function<ItemContent, Boolean> filter;

    public ItemFilter(Function<ItemContent, Boolean> filter) {
        this.filter = filter;
    }

    public boolean setFlagThenGet(ItemContent t) {
        if (!isFilterFlag) {
            return false;
        }
        boolean tmp = isFilterFlag;
        isFilterFlag = filter.apply(t);
        return tmp;
    }

    public boolean needFilter() {
        return isFilterFlag;
    }
}
